/*
 * Copyright (c) 2017-2021 duobaoyu, Inc. All rights reserved.<br/>
 * Unless required by applicable law or agreed to in writing, <br/>
 * Unauthorized use and distribution by any person or organization is prohibited.<br/>
 */
package com.shangsi.originparser;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author dzd
 * @date 2021-12-26
 */
@Component
public class HeaderOriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String header = httpServletRequest.getHeader("origin");
        if (StringUtils.isEmpty(header)){
            return "blank";
        }
        return header;
    }
}
